package com.woniuxy.utils;

import javax.servlet.*;
import java.io.IOException;

//统计controller访问用的时间
public class TimeFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        chain.doFilter(request,response);//表示放行
        long end =System.currentTimeMillis();
        System.err.println("后端耗时"+(end-start)+"ms");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
